package crl.encrypt.ext
{
	import com.swfwire.decompiler.AsyncSWFWriter;
	import com.swfwire.decompiler.SWFByteArray;
	import com.swfwire.decompiler.SWFWriterContext;
	import com.swfwire.decompiler.data.swf.tags.SWFTag;
	import com.swfwire.decompiler.data.swf.tags.UnknownTag;
	import com.swfwire.decompiler.data.swf9.tags.DefineBinaryDataTag;
	import com.swfwire.decompiler.data.swf9.tags.DoABCTag;
	import com.swfwire.decompiler.data.swf9.tags.SymbolClassTag;
	
	import crl.encrypt.ext.tag.TagDoABCDeprecated;
	
	public class ExAsyncSWFWriter extends AsyncSWFWriter
	{
		public function ExAsyncSWFWriter()
		{
			super();
		}
		
		override protected function writeTag(context:SWFWriterContext, tag:SWFTag):void
		{
			switch(Object(tag).constructor)
			{
				case TagDoABCDeprecated :
					tag.header.type=82;
					writeDoABCTag(context, TagDoABCDeprecated(tag));
					break;
				case DoABCTag:
					writeDoABCTag(context, DoABCTag(tag));
					break;
				case SymbolClassTag:
					writeSymbolClassTag(context, SymbolClassTag(tag));
					break;
				case DefineBinaryDataTag :
					writeDefineBinaryDataTag(context,DefineBinaryDataTag(tag))
					break;
				default:
					writeUnknownTag(context,UnknownTag(tag));
					break;
			}
		}
		
		
		public function writeDefineBinaryDataTag(context:SWFWriterContext, tag:DefineBinaryDataTag):void{
			var bytes:SWFByteArray=context.bytes;
			bytes.writeUI16(tag.characterId);// = context.bytes.readUI16();
			bytes.writeUI32(tag.reserved);// = context.bytes.readUI32();
			bytes.writeBytes(tag.data);// = new ByteArray();
		}
			
	}
}